﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Search.ascx.cs" Inherits="Components_Search" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True">
</telerik:RadScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <telerik:radformdecorator id="QsfFromDecorator" runat="server" decoratedcontrols="All" enableroundedcorners="false" />
<div class="leftCol">
     <div class="around">
        <div class="greenText18">Tìm kiếm</div>
        <div class="greenLine"></div>
        <div class="yellowLine"></div>
    </div><!---around------>

    <div class="around">    
    <table>
        <tr>
            <td>Tên gạo</td>
            <td colspan="1" style="width:300px;"><telerik:RadTextBox ID="txtProductName" CssClass="formBox300Bold"  Width="100%" EmptyMessage="Nhập tên gạo" runat="server"/> <br /></td>
             <td>Giá từ </td>
            <td style="width:200px;"><telerik:RadTextBox ID="txtPriceFrom" CssClass="formBox" EmptyMessage="Giá gạo từ" Width="100%"  runat="server" onkeyup = "FormatNumber(this)"/></td>
        </tr>
        <tr>
            <td>Loại gạo</td>
            <td style="width:300px;"><asp:DropDownList ID="cboProductType"  runat="server" CssClass="formBoxSelect" Width="100%" ></asp:DropDownList></td>
            <td>Giá đến </td>
            <td style="width:200px;">
               <telerik:RadTextBox ID="txtPriceTo" CssClass="formBox" onkeyup = "FormatNumber(this)"  EmptyMessage="Giá gạo đến" Width="100%" runat="server"/>
            </td>
        </tr>
        
    </table>
                    
</div><!---around------>
    <div style="text-align:center;">
        <asp:Button ID="btnSearch" runat="server" Text="TÌM KIẾM" CssClass="greenBtn" OnClick="btnSearch_Click" />
    </div>

<div class="around">
    <div class="greenText18">Kết quả tìm kiếm</div>
    <div class="greenLine"></div>
    <div class="yellowLine"></div>
    <div id="div_NoData" runat="server"></div>
</div><!---around--->

<div class="around"> 
        <div class="four">
        <!-- ListView -->
    <asp:ListView ID="lvProductNew"  runat="server" >
        <LayoutTemplate>
           <div  id="div_listNew" runat="server"><asp:PlaceHolder ID="itemPlaceholder" runat="server" /></div>      
        </LayoutTemplate>
        <ItemTemplate>
            <div class="greenBg">
           
            <div class="info">
                <center>
                    <b><%#Eval("ProductName")%></b><br />
                    <a href='<%#Utils.RemoveUnicode(Eval("Link").ToString())%>'>
                        <img src="<%#Eval("ImagePath")%>" class="pic" alt='<%#Eval("ProductName")%>' />        
                    </a>
                    <br />
                    <b class="price"><%# String.Format("{0:#,#.##}",Eval("Price"))%> vnđ/kg</b>
                    <asp:Button runat="server"  class="greenBtnSmall" ID="btnOrder" Text="Đặt mua"
                        CommandArgument='<%#Eval("ProductID") + "@" + Eval("ProductName") + "@" +Eval("ProductCode")+"@"+ Eval("ImagePath") +"@"+ Eval("Price") %>'  OnCommand="btnOrder_Command"/>
                    <!--<input type="btnOrder" class="greenBtn" value="đặt mua" /> -->
                </center>
            </div><!--info----->
            </div>
        </ItemTemplate>
    </asp:ListView>
    <!-- End ListView -->     
    <div class="clearBoth"></div>          
    </div><!--four--->
</div>
</div>
 </ContentTemplate>
</asp:UpdatePanel>
<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>
<script>
    function FormatNumber(obj) {

        var x;

        if (eval(obj))

            x = eval(obj).value;

        else

            x = obj;

        var num = x.replace(/$|,/g, '');

        if (isNaN(num)) { num = ""; }

        sign = (num == (num = Math.abs(num)));

        num = Math.floor(num * 100 + 0.50000000001);

        num = Math.floor(num / 100).toString();

        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++) {

            num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));

        }

        eval(obj).value = num;

    }
</script>